package com.westa.smallshop.setting;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.view.View;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.westa.smallshop.R;
import com.westa.smallshop.common.BaseFragment;
import com.westa.smallshop.util.Global;

import butterknife.OnClick;

/**
 * Created by cy on 11/6/16.
 */

public class SettingFragment extends BaseFragment{

    public SettingFragment() {
        //Required empty here
    }

    public static SettingFragment newInstance() {
        SettingFragment fragment = new SettingFragment();
        return fragment;
    }


    @Override
    public int getCreateViewLayoutRes() {
        return R.layout.fragment_setting;
    }

    @Override
    public void initView() {

    }

    @OnClick({R.id.ll_setting_logout, R.id.ll_setting_about_us,
            R.id.ll_setting_thanks, R.id.ll_setting_join_us})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_setting_logout:
                new MaterialDialog.Builder(getActivity()).content("确定退出登录？")
                        .positiveText(R.string.general_confirm)
                        .positiveColor(Color.RED)
                        .negativeText(R.string.general_cancel)
                        .negativeColor(Color.GRAY)
                        .onPositive(new MaterialDialog.SingleButtonCallback() {
                            @Override
                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                Global.logout(getActivity());
                            }
                        })
                        .show();
                break;
            default:
                break;
        }
    }
}
